package com.szrt.java.day20161226.demo09;

import java.util.Scanner;

/**
 * 方法的调用
 * 
 * 1：你需要掌握层次关系
 * 2：你需要掌握方法需要什么参数
 * 3：方法一点给要调用之后才能干活
 * 
 * @author zsrt
 *
 */
public class Cal {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		System.out.println("请输入第1个数：");
		int one = sc.nextInt();
		
		System.out.println("请输入运算符号，如：+ - * / %");
		String symbol = sc.next();
		
		System.out.println("请输入第2个数：");
		int two = sc.nextInt();
		
		sc.close();
		
		switch (symbol) {
		case "+": add(one,two); break;
		case "-": sub(one,two); break;
		case "*": cheng(one,two); break;
		case "/": chu(one,two); break;
		case "%": mod(one,two); break;
		default:break;
		}
		
		cal(one,symbol,two);
		
	}
	
	public static void cal(int one,String symbol,int two){
		
		switch (symbol) {
		case "+": add(one,two); break;
		case "-": sub(one,two); break;
		case "*": cheng(one,two); break;
		case "/": chu(one,two); break;
		case "%": mod(one,two); break;
		default:break;
		}
	}
	
	/**
	 * 计算两个数之和
	 * @param a 
	 * @param b
	 * @return
	 */
	public static int add(int a,int b){
		int result = a+b;
		System.out.println(result);
		return result;
	}
	
	/**
	 * 计算两个数之差
	 * @param a
	 * @param b
	 * @return
	 */
	public static int sub(int a,int b){
		int result = a-b;
		System.out.println(result);
		return result;
	}
	
	/**
	 * 计算两个数相乘
	 * @param a
	 * @param b
	 * @return
	 */
	public static int cheng(int a,int b){
		int result = a*b;
		System.out.println(result);
		return result;
	}
	
	/**
	 * 两个数求模
	 * @param a
	 * @param b
	 * @return
	 */
	public static int chu(int a,int b){
		int result = a/b;
		System.out.println(result);
		return result;
	}
	
	/**
	 * 
	 * @param a
	 * @param b
	 * @return
	 */
	public static int mod(int a,int b){
		int result = a%b;
		System.out.println(result);
		return result;
	}

}
